<?php Yii::import('ext.imperavi-redactor-widget.ImperaviRedactorWidget'); ?>

<div class="form">

	<?php
		$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
			'id'=>'words-form',
			'type'=>'horizontal',
			'enableAjaxValidation'=>false,
			'htmlOptions' => array('enctype'=>'multipart/form-data', 'class'=>'well'),
		)); 
	?>

	<?php echo $form->errorSummary($model); ?>
			
		<div class="row">
			<?php echo $form->labelEx($model,'company'); ?>
			<?php 
				echo $form->textField($model,'company',array('size'=>60,'maxlength'=>100)); 
				echo '<span class="editable-clear-x-f"></span>'; 
			?>
			<?php echo $form->error($model,'company'); ?>
		</div>	
		
		<div class="row">
			<?php echo $form->labelEx($model,'src'); ?>
			<?php 
				if (Yii::app()->user->getState('src')) { $model->src = Yii::app()->user->getState('src'); Yii::app()->user->setState('src', ''); } 
				echo $form->textField($model,'src',array('size'=>60,'maxlength'=>300)); 
				echo '<span class="editable-clear-x-f"></span>';
			?>
			<?php echo $form->error($model,'src'); ?>
		</div>			
		
		<div class="row">
			<?php echo $form->labelEx($model,'title'); ?>
			<?php 
				echo $form->textField($model,'title',array('size'=>60,'maxlength'=>100)); 
				echo '<span class="editable-clear-x-f"></span>';
			?>
			<?php echo $form->error($model,'title'); ?>
		</div>	
		
		<div class="row">
			<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Уточнить&nbsp;&nbsp;</label>' . $form->checkBox($model,'title_c',array('onchange'=>'$.fn.showTitle();')) . "</div>"; ?>			
			<?php echo $form->error($model,'title_c'); ?>
		</div>		
		
			<!-- ----------- -->	
			<div class="<?php if (!$model->title_c) { echo 'row hide'; } else { echo 'row'; } ?>" id="block-title">
				<div class="row" style="border-left:4px solid #777;">
					<?php 
						echo '&nbsp;'.$form->textField($model,'title_ex',array('size'=>60,'maxlength'=>100)); 
						echo '<span class="editable-clear-x-f"></span>';
					?>
					<?php echo $form->error($model,'title_ex'); ?>
				</div>				
				<i>Слово или выражение непосредственно <strong>перед</strong> словом.</i>
			</div>		
			<!-- ----------- -->	

		<div class="row">
			<?php echo $form->labelEx($model,'target'); ?>
			<?php 
				echo $form->textField($model,'target',array('size'=>60,'maxlength'=>300)); 
				echo '<span class="editable-clear-x-f"></span>';
			?>
			<?php echo $form->error($model,'target'); ?>
		</div>			
		
		<div class="row">
			<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Включено&nbsp;&nbsp;</label>' . $form->checkBox($model,'active_w',array('checked'=>'checked')) . "</div>"; ?>
			<?php echo $form->error($model,'active_w'); ?>
		</div>

		<div class="row">
			<?php echo $form->labelEx($model,'d_start_w'); ?>
			<?php 
				$this->widget('zii.widgets.jui.CJuiDatePicker',array(
					'name'=>'d_start_w',
					'model' => $model,
					'attribute' => 'd_start_w',
					'language' => 'ru',
					'options'=>array(
						'showAnim'=>'fold',
					),
					'htmlOptions'=>array(
						'style'=>'height:20px;'
					),
				)); 
			?>
			<?php echo $form->error($model,'d_start_w'); ?>
		</div>

		<div class="row">
			<?php echo $form->labelEx($model,'d_end_w'); ?>
			<?php 
				$this->widget('zii.widgets.jui.CJuiDatePicker',array(
					'name'=>'d_end_w',
					'model' => $model,
					'attribute' => 'd_end_w',
					'language' => 'ru',
					'options'=>array(
						'showAnim'=>'fold',
					),
					'htmlOptions'=>array(
						'style'=>'height:20px;'
					),
				)); 
			?>
			<?php echo $form->error($model,'d_end_w'); ?>
		</div>

		<div class="row">
			<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Геотаргетинг&nbsp;&nbsp;</label>' . $form->checkBox($model,'show_geot',array('onchange'=>'$.fn.showGeot();')) . "</div>"; ?>			
			<?php echo $form->error($model,'show_geot'); ?>
		</div>
		
		<!-- ----------- -->	
		<div class="<?php if (!$model->show_geot) { echo 'row hide'; } else { echo 'row'; } ?>" style="border-bottom:1px dashed #999;border-top:1px dashed #999;" id="block-geot">			
			<div class="row">
				<?php echo $form->labelEx($model,'country'); ?>
				<?php 
					$autocompleteConfigCountry = array(
						'model'=>$model,
						'attribute'=>'country',
						'value'=>$model->country,
						'source' =>'js:function(request, response) {
							$.getJSON("'.$this->createUrl('words/autocompletecountry').'", {
								term: request.term.split(/,s*/).pop().trim()
							}, response);
						}',
						'options' => array(
							'minLength' => '2',
							'showAnim' => 'fold',
							'search' =>'js: function() {
								var term = this.value.split(/,s*/).pop().trim();
								if(term.length < 2) {
									return false;
								}
							 }',
							'focus' =>'js: function() {
								return false;
							 }',
							'select' =>'js: function(event, ui) {
								var terms =  this.value.split(/,s*/);
								terms.pop();
								terms.push(ui.item.value.trim());
								terms.push("");
								this.value = terms.join(", ");
								$("#icountry").val(ui.item.id.trim()); 
								return false;
							}',
						),
						'htmlOptions' => array("class"=>"input-big search-query"),
					);
					$this->widget('zii.widgets.jui.CJuiAutoComplete', $autocompleteConfigCountry); 
					echo '<span class="editable-clear-x-f"></span>';
				?>
				<?php echo '<input type="hidden" id="icountry" name="icountry">' ?>
			</div>
			
			<div class="row">
				<?php echo $form->labelEx($model,'region'); ?>
				<?php 
					$autocompleteConfigRegion = array(
						'model'=>$model,
						'attribute'=>'region',
						'value'=>$model->region,
						'source' =>'js:function(request, response) {
							$.getJSON("'.$this->createUrl('words/autocompleteregion').'", {
								term: request.term.split(/,s*/).pop().trim(),
								country_id: $("#Words_country").val() ? $("#icountry").val() : "",
							}, response);
						}',
						'options' => array(
							'minLength' => '2',
							'showAnim' => 'fold',
							'search' =>'js: function() {
								var term = this.value.split(/,s*/).pop().trim();
								if(term.length < 2) {
									return false;
								}
							 }',
							'focus' =>'js: function() {
								return false;
							 }',
							'select' =>'js: function(event, ui) {
								var terms =  this.value.split(/,s*/);
								terms.pop();
								terms.push(ui.item.value.trim());
								terms.push("");
								this.value = terms.join(", ");
								$("#iregion").val(ui.item.id.trim());
								return false;
							}',
						),
						'htmlOptions' => array("class"=>"input-big search-query"),
					);
					$this->widget('zii.widgets.jui.CJuiAutoComplete', $autocompleteConfigRegion); 
					echo '<span class="editable-clear-x-f"></span>';
				?>
				<?php echo '<input type="hidden" id="iregion" name="iregion">' ?>
			</div>			
				
			<div class="row">
				<?php echo $form->labelEx($model,'city'); ?>
				<?php 
					$autocompleteConfigCity = array(
						'model'=>$model,
						'attribute'=>'city',
						'value'=>$model->city,
						'source' =>'js:function(request, response) {
							$.getJSON("'.$this->createUrl('words/autocompletecity').'", {
								term: request.term.split(/,s*/).pop().trim(),
								country_id: $("#Words_country").val() ? $("#icountry").val() : "",
								region_id: $("Words_region").val() ? $("#iregion").val() : "",
							}, response);
						}',
						'options' => array(
							'minLength' => '2',
							'showAnim' => 'fold',
							'search' =>'js: function() {
								var term = this.value.split(/,s*/).pop().trim();
								if(term.length < 2)
									return false;
							 }',
							'focus' =>'js: function() {
								return false;
							 }',
							'select' =>'js: function(event, ui) {
								var terms =  this.value.split(/,s*/);
								terms.pop();
								terms.push(ui.item.value.trim());
								terms.push("");
								this.value = terms.join(", ");
								return false;
							}',
						),
						'htmlOptions' => array("class"=>"input-big search-query"),
					);
					$this->widget('zii.widgets.jui.CJuiAutoComplete', $autocompleteConfigCity);
					echo '<span class="editable-clear-x-f"></span>';					
				?>
			</div>	

			<div class="row">
				<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Все кроме выбранных&nbsp;&nbsp;</label>' . $form->checkBox($model,'geot_invert') . "</div>"; ?>			
				<?php echo $form->error($model,'geot_invert'); ?>
			</div>	
		</div>
		<!-- ----------- -->
		
		<div class="row">
			<?php echo $form->labelEx($model,'type'); ?>
			<?php $listTypes = array('link'=>'Ссылка','banner'=>'Баннер','video'=>'Видео');	?>
			<?php echo $form->dropDownList($model,'type',$listTypes,array('onchange'=>'$.fn.getType(this.value);')); ?>	
			<?php echo $form->error($model,'type'); ?>
		</div>

		<!-- ----------- -->	
		<div class="<?php if ($model->type!='banner') { echo 'row hide'; } else { echo 'row'; } ?>" id="block-banner">		
			<div class="row">
				<?php echo $form->labelEx($model,'source_ban'); ?>
				<?php 
					$this->widget('ImperaviRedactorWidget', array(
						'model' => $model,
						'attribute' => 'source_ban',
						'options' => array(
							'lang' => 'ru',
							'toolbar' => true,
							'iframe' => true,
							//'minHeight' => 200,
							//'autoresize' => true,
							'buttons' => array('image','|','html'),
							'imageUpload' => Yii::app()->createUrl('words/upload'),
							'imageUploadErrorCallback'=>'js:function(obj, json){ alert(json.error); }',
						),
						'htmlOptions' => array('style' => 'width: 100%; height: 300px;'),
					)); 
				?>					
				<?php echo $form->error($model,'source_ban'); ?>
			</div>
			
			<div class="row">
				<?php echo $form->labelEx($model,'width_ban'); ?>
				<?php 
					echo $form->textField($model,'width_ban'); 
					echo '<span class="editable-clear-x-f"></span>';
				?>
				<?php echo $form->error($model,'width_ban'); ?>
			</div>

			<div class="row">
				<?php echo $form->labelEx($model,'height_ban'); ?>
				<?php 
					echo $form->textField($model,'height_ban'); 
					echo '<span class="editable-clear-x-f"></span>';
				?>
				<?php echo $form->error($model,'height_ban'); ?>
			</div>		
			
			<div class="row">
				<?php echo $form->labelEx($model,'theme_ban'); ?>		
				<?php
					$this->widget('ext.SMiniColors.SActiveColorPicker', array(
						'model' => $model,
						'attribute' => 'theme_ban',
						'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
						'options' => array(), // jQuery plugin options
						'htmlOptions' => array(), // html attributes
					));		
					echo '<span class="editable-clear-x-f"></span>';					
				?>
				<?php echo $form->error($model,'theme_ban'); ?>
			</div>			
			
			<div class="row">
				<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Требует закрытия&nbsp;&nbsp;</label>' . $form->checkBox($model,'need_to_close_ban') . "</div>"; ?>
				<?php echo $form->error($model,'need_to_close_ban'); ?>
			</div>	
			
			<div class="row">
				<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Показать заголовок&nbsp;&nbsp;</label>' . $form->checkBox($model,'show_header_ban',array('onchange'=>'$.fn.showHeaderBan();')) . "</div>"; ?>			
				<?php echo $form->error($model,'show_header_ban'); ?>
			</div>
			
				<!-- ----------- -->		
				<div class="<?php if (!$model->show_header_ban) { echo 'row hide'; } else { echo 'row'; } ?>" style="border-bottom:1px dashed #999;border-top:1px dashed #999;" id="block-header-ban">			
					<div class="row">
						<?php echo $form->labelEx($model,'caption_ban'); ?>
						<?php 
							$this->widget('ImperaviRedactorWidget', array(
								'model' => $model,
								'attribute' => 'caption_ban',
								'options' => array(
									'lang' => 'ru',
									'toolbar' => true,
									'iframe' => true,
									'tidyHtml' => false,
									'buttons' => array('html','|','formatting','|','bold','italic','deleted','|','unorderedlist','orderedlist','outdent','indent','|','table','link','|','alignment','|','horizontalrule','|','image'),
								),
								'plugins' => array('fontcolor' => array('js' => array('fontcolor.js'))),
								'htmlOptions' => array('style' => 'width: 100%; height: 300px;'),
							)); 
						?>					
						<?php echo $form->error($model,'caption_ban'); ?>
					</div>	

					<div class="row">
						<?php echo $form->labelEx($model,'ccap_ban'); ?>		
						<?php
							$this->widget('ext.SMiniColors.SActiveColorPicker', array(
								'model' => $model,
								'attribute' => 'ccap_ban',
								'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
								'options' => array(), // jQuery plugin options
								'htmlOptions' => array(), // html attributes
							));	
							echo '<span class="editable-clear-x-f"></span>';							
						?>
						<?php echo $form->error($model,'ccap_ban'); ?>
					</div>						
				</div>
				<!-- ----------- -->		
			
			<div class="row">
				<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Показать footer&nbsp;&nbsp;</label>' . $form->checkBox($model,'show_footer_ban',array('onchange'=>'$.fn.showFooterBan();')) . "</div>"; ?>
				<?php echo $form->error($model,'show_footer_ban'); ?>
			</div>
			
				<!-- ----------- -->		
				<div class="<?php if (!$model->show_footer_ban) { echo 'row hide'; } else { echo 'row'; } ?>" style="border-bottom:1px dashed #999;border-top:1px dashed #999;" id="block-footer-ban">			
					<div class="row">
						<?php echo $form->labelEx($model,'footer_ban'); ?>
						<?php 
							$this->widget('ImperaviRedactorWidget', array(
								'model' => $model,
								'attribute' => 'footer_ban',
								'options' => array(
									'lang' => 'ru',
									'toolbar' => true,
									'tidyHtml' => false,
									'iframe' => true,
									'buttons' => array('html','|','formatting','|','bold','italic','deleted','|','unorderedlist','orderedlist','outdent','indent','|','table','link','|','alignment','|','horizontalrule','|','image'),
								),
								'plugins' => array('fontcolor' => array('js' => array('fontcolor.js'))),
								'htmlOptions' => array('style' => 'width: 100%; height: 300px;'),
							)); 
						?>	
						<?php echo $form->error($model,'footer_ban'); ?>
					</div>	

					<div class="row">
						<?php echo $form->labelEx($model,'cfoot_ban'); ?>		
						<?php
							$this->widget('ext.SMiniColors.SActiveColorPicker', array(
								'model' => $model,
								'attribute' => 'cfoot_ban',
								'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
								'options' => array(), // jQuery plugin options
								'htmlOptions' => array(), // html attributes
							));		
							echo '<span class="editable-clear-x-f"></span>';							
						?>
						<?php echo $form->error($model,'cfoot_ban'); ?>
					</div>						
				</div>
				<!-- ----------- -->		
		</div>

		<!-- ----------- -->
		<div class="<?php if ($model->type!='video') { echo 'row hide'; } else { echo 'row'; } ?>" id="block-video">		
			<div class="row">
				<?php echo $form->labelEx($model,'source_vid'); ?>
				<?php 
					$this->widget('ImperaviRedactorWidget', array(
						'model' => $model,
						'attribute' => 'source_vid',
						'options' => array(
							'lang' => 'ru',
							'toolbar' => true,
							'iframe' => true,
							//'visual' => false,
							'paragraphy' => false,
							'buttons' => array('html','file'),
							'fileUpload' => Yii::app()->createUrl('words/upload'),
							'fileUploadErrorCallback'=>'js:function(obj, json){ alert(json.error); }',
						),
						'htmlOptions' => array('style' => 'width: 100%; height: 300px;'),
					));
				?>					
				<?php echo $form->error($model,'source_vid'); ?>
			</div>
			
			<div class="row">
				<?php echo $form->labelEx($model,'width_vid'); ?>
				<?php 
					echo $form->textField($model,'width_vid'); 
					echo '<span class="editable-clear-x-f"></span>';
				?>
				<?php echo $form->error($model,'width_vid'); ?>
			</div>

			<div class="row">
				<?php echo $form->labelEx($model,'height_vid'); ?>
				<?php 
					echo $form->textField($model,'height_vid'); 
					echo '<span class="editable-clear-x-f"></span>';
				?>
				<?php echo $form->error($model,'height_vid'); ?>
			</div>			

			<div class="row">
				<?php echo $form->labelEx($model,'screen_vid_f'); ?>
				<?php echo $form->fileField($model,'screen_vid_f'); ?>
				<?php echo $form->error($model,'screen_vid_f'); ?>
			</div>		
			
			<div class="<?php if (!$model->screen_vid) { echo 'row hide'; } else { echo 'row'; } ?>">
				<?php 
					echo $form->textField($model,'screen_vid',array('size'=>60,'maxlength'=>300)); 
					echo '<span class="editable-clear-x-f"></span>';
				?>
				<?php echo $form->error($model,'screen_vid'); ?>
			</div>					
			
			<div class="row">
				<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Автозапуск&nbsp;&nbsp;</label>' . $form->checkBox($model,'ap_vid') . "</div>"; ?>
				<?php echo $form->error($model,'ap_vid'); ?>
			</div>			
			
			<div class="row">
				<?php echo $form->labelEx($model,'theme_vid'); ?>		
				<?php
					$this->widget('ext.SMiniColors.SActiveColorPicker', array(
						'model' => $model,
						'attribute' => 'theme_vid',
						'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
						'options' => array(), // jQuery plugin options
						'htmlOptions' => array(), // html attributes
					));	
					echo '<span class="editable-clear-x-f"></span>';					
				?>
				<?php echo $form->error($model,'theme_vid'); ?>
			</div>				
			
			<div class="row">
				<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Требует закрытия&nbsp;&nbsp;</label>' . $form->checkBox($model,'need_to_close_vid') . "</div>"; ?>
				<?php echo $form->error($model,'need_to_close_vid'); ?>
			</div>	
			
			<div class="row">
				<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Показать заголовок&nbsp;&nbsp;</label>'.$form->checkBox($model,'show_header_vid',array('onchange'=>'$.fn.showHeaderVid();'))."</div>"; ?>
				<?php echo $form->error($model,'show_header_vid'); ?>
			</div>
			
				<!-- ----------- -->		
				<div class="<?php if (!$model->show_header_vid) { echo 'row hide'; } else { echo 'row'; } ?>" style="border-bottom:1px dashed #999;border-top:1px dashed #999;" id="block-header-vid">			
					<div class="row">
						<?php echo $form->labelEx($model,'caption_vid'); ?>
						<?php 
							$this->widget('ImperaviRedactorWidget', array(
								'model' => $model,
								'attribute' => 'caption_vid',
								'options' => array(
									'lang' => 'ru',
									'toolbar' => true,
									'iframe' => true,
									'paragraphy' => false,
									'tidyHtml' => false,
									'buttons' => array('html','|','formatting','|','bold','italic','deleted','|','unorderedlist','orderedlist','outdent','indent','|','table','link','|','alignment','|','horizontalrule','|','image'),
									//'buttons' => array('html','|','formatting','|','bold','italic','deleted','|','unorderedlist','orderedlist','outdent','indent','|','table','link','|','alignment','|','horizontalrule'),
								),
								'plugins' => array('fontcolor' => array('js' => array('fontcolor.js'))),
								'htmlOptions' => array('style' => 'width: 100%; height: 300px;'),
							)); 
						?>	
						<?php echo $form->error($model,'caption_vid'); ?>
					</div>	
					
					<div class="row">
						<?php echo $form->labelEx($model,'ccap_vid'); ?>		
						<?php
							$this->widget('ext.SMiniColors.SActiveColorPicker', array(
								'model' => $model,
								'attribute' => 'ccap_vid',
								'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
								'options' => array(), // jQuery plugin options
								'htmlOptions' => array(), // html attributes
							));		
							echo '<span class="editable-clear-x-f"></span>';							
						?>
						<?php echo $form->error($model,'ccap_vid'); ?>
					</div>						
				</div>
				<!-- ----------- -->		
			
			<div class="row">
				<?php echo '<div style="margin:10px 0 15px 0;"><label style="display:inline;">Показать footer&nbsp;&nbsp;</label>' . $form->checkBox($model,'show_footer_vid',array('onchange'=>'$.fn.showFooterVid();')) . "</div>"; ?>	
				<?php echo $form->error($model,'show_footer_vid'); ?>
			</div>
			
				<!-- ----------- -->		
				<div class="<?php if (!$model->show_footer_vid) { echo 'row hide'; } else { echo 'row'; } ?>" style="border-bottom:1px dashed #999;border-top:1px dashed #999;" id="block-footer-vid">			
					<div class="row">
						<?php echo $form->labelEx($model,'footer_vid'); ?>
						<?php 
							$this->widget('ImperaviRedactorWidget', array(
								'model' => $model,
								'attribute' => 'footer_vid',
								'options' => array(
									'lang' => 'ru',
									'toolbar' => true,
									'iframe' => true,
									'tidyHtml' => false,
									'buttons' => array('html','|','formatting','|','bold','italic','deleted','|','unorderedlist','orderedlist','outdent','indent','|','table','link','|','alignment','|','horizontalrule','|','image'),
								),
								'plugins' => array('fontcolor' => array('js' => array('fontcolor.js'))),								
								'htmlOptions' => array('style' => 'width: 100%; height: 300px;'),
							)); 
						?>	
						<?php echo $form->error($model,'footer_vid'); ?>
					</div>	

					<div class="row">
						<?php echo $form->labelEx($model,'cfoot_vid'); ?>		
						<?php
							$this->widget('ext.SMiniColors.SActiveColorPicker', array(
								'model' => $model,
								'attribute' => 'cfoot_vid',
								'hidden'=>false, // defaults to false - can be set to hide the textarea with the hex
								'options' => array(), // jQuery plugin options
								'htmlOptions' => array(), // html attributes
							));		
							echo '<span class="editable-clear-x-f"></span>';							
						?>
						<?php echo $form->error($model,'cfoot_vid'); ?>
					</div>					
				</div>
				<!-- ----------- -->		
		</div>	
		<!-- ----------- -->	
		
		<br/><br/>
		<div class="row">
			<?php 
				$this->widget('bootstrap.widgets.TbButton', array(
					'label' => $model->isNewRecord ? 'Создать' : 'Сохранить',
					'buttonType' => 'submit',
					'size' => 'Normal', 
				));
				echo "&nbsp;";
				$this->widget('bootstrap.widgets.TbButton', array(
					'label' => 'Отмена',
					'size' => 'Normal', 
					'url'=>array('admin'),
				));
				echo "&nbsp;";
				$this->widget('bootstrap.widgets.TbButton', array(
					'label' => 'Preview',
					'size' => 'Normal', 
					'buttonType' => 'ajaxSubmit',
					'ajaxOptions' => array(
						'type' => 'POST',	
						'success' => 'js:function(resp){ $.fn.getbanner(resp); return false; }',
						'error' => 'js:function(e){ console.log(e); }',
					),
					
				));			
			?>			
		</div>

	<?php $this->endWidget(); ?>
	
	<?php
		$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
				'id' => 'preview',
				'options' => array(
					'title' => 'Preview',
					'autoOpen' => false,
					'draggable' => false,
					'resizable' => false,					
					'modal' => true,
					'width' => 450,
				)
		));
	?>

	<link rel='stylesheet' type='text/css' href='http://www.elcp.ru/mon/images/banners/jquery.cluetip.css' />
	<!--<link rel='stylesheet' type='text/css' href='/images/jquery.cluetip.css' /> 	-->
	<div id="frame"></div>
	<script type="text/javascript">
		$.fn.getbanner = function(rel) {
			var subdir = (window.location.pathname.indexOf("mon") !== -1) ? "/mon" : (window.location.pathname.indexOf("crm") !== -1) ? "/crm" : "";
			//var subdir = "";
			$.ajax({ 
				url: subdir+'/images/uploads/'+rel+'.html', 
				success: function(response) {
					$("#frame").html("<div style='text-align:center;'><div id='cluetip' class='cluetip ui-widget ui-cluetip clue-bottom-jtip cluetip-jtip'><div class='cluetip-outer'><h3 class='cluetip-title ui-cluetip-header'></h3><div class='cluetip-inner ui-cluetip-content'>"+response+"</div></div></div></div>");
					if (caption) { $(".cluetip-title").html(caption); }
					if (cluetipClass) { 
						$("#cluetip").removeClass('cluetip-jtip').addClass('cluetip-'+cluetipClass); 
						$("#cluetip-inner").addClass('cluetip-'+cluetipClass+''); 
					}
					if (caption_bg) { $(".ui-cluetip-header").css('background-color',caption_bg); }					
					if (win_bg) { $(".cluetip-inner").css('background-color',win_bg); }	
					$("#preview").dialog("open");
				}, 
				error: function(XMLHttpRequest, textStatus, errorThrown) { console.log(errorThrown); } 
			});
		};
	</script>

	<?php $this->endWidget('zii.widgets.jui.CJuiDialog'); ?>	

	<!-- ----------- -->	
	<script type="text/javascript">
		
		$(function () { if ($("#Words_type").val() == "link") { $("#yt1").hide(); }	});	
		
		$.fn.getType = function(data) {	
			if (data == "link") { $("#block-banner").hide("slow"); $("#block-video").hide("slow"); $("#yt1").hide(); }
			if (data == "banner") {	$("#block-banner").toggle("slow"); $("#block-video").hide("slow");  $("#yt1").show(); }
			if (data == "video") { $("#block-video").toggle("slow"); $("#block-banner").hide("slow");  $("#yt1").show(); }
		}		
		
		$.fn.showTitle = function() { $('#block-title').toggle("slow"); }	
		
		$.fn.showGeot = function() { $('#block-geot').toggle("slow"); }	
		
		$.fn.showHeaderBan = function() { $('#block-header-ban').toggle("slow"); }	
		
		$.fn.showFooterBan = function() { $('#block-footer-ban').toggle("slow"); }		
		
		$.fn.needtoCloseVid = function() { $('#show-close-vid').toggle("slow"); }		
		
		$.fn.showHeaderVid = function() { $('#block-header-vid').toggle("slow"); }	
		
		$.fn.showFooterVid = function() { $('#block-footer-vid').toggle("slow"); }	

		$(".editable-clear-x-f").click(function() {	$(this).siblings("input[type=text]").val(null);	});	
		
	</script>

</div><!-- form -->